﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    class Connection
    {
        IList<Flight> flights;
     //   IList<City> cities;
       // IList<City> sequenceOfParentCities;
     //   IList<Flight> pureFlights;
        City departureCity { get; set; }
        City destinationCity { get; set; }
        int totalTime { get; set; }
        int totalPrice { get; set; }
        int numberOfFlightChange { get; set; }
        int noOfseatsLeft { get; set; }
        int noOfSeatsReservedByCustomer { get; set; }
        public Connection()
        {
            flights = new List<Flight>();
       //     cities = new List<City>();
//sequenceOfParentCities = new List<City>();
        }
         public IList<Flight> FlightList()
        {
            return flights;
        }
        public void SetFlightList(IList<Flight> value)
        {
            flights = value;
        }
        public void RemoveFlight(Flight flight)
        {
            flights.Remove(flight);
        }
 
             public void AddFlight(Flight flight)
        {
            flights.Add(flight);
        }
        public IList<Flight> MakeFlightsOfCities(IList<City> list)
        {
            for(int i = 0; i < list.Count() - 1; i++)
            {
                City c = list[i];
                City x = list[i + 1];
                Flight y = c.Flights().Single(z => z.To == x);
                flights.Add(y);
            }
            return flights;
        }
        
    }
}
    //    public void AddCity(City city)
    //    {
    //        cities.Add(city);
    //    }
   /*     public void SetCityList(IList<City> value)
        {
            cities = value;
            foreach(Flight f in flights)
            {
                foreach(City c in cities)
                {
                    foreach(Flight v in c.Flights())
                    {
                        if(f != v)
                        {
                            v.SetFound(true);
                        }
                    }

                }
            }
        }
        public void PurifyFlights()
        {
            foreach(Flight f in flights)
            {
                if (f.Found != true)
                    flights.Remove(f);
            }
        }
        */
        /*public IList<City> CitiesList()
        {
            return cities;
        }
       
        
      
        public void SetCityList(IList<Flight> value)
        {

        }
      
        
        /*public IList<City> GetSequenceOfParentCities(City city)
        {
            foreach (City c in GetParentsOfThisCity(city))
            {
                sequenceOfParentCities.Add(c);
            }
            return sequenceOfParentCities;

        }


        public IList<City> GetParentsOfThisCity(City city)
        {
            IList<City> listOfCities = new List<City>();
            foreach (City c in cities)
            {
                foreach (City i in GetAdjacencies(c))
                {
                    if (i == city)
                    {
                        listOfCities.Add(c);
                    }
                }

            }

            return listOfCities;
        }
        public IList<City> GetAdjacencies(City city)
        {
            IList<City> list = new List<City>();
            foreach (Flight f in city.Flights())
            {
                list.Add(f.To);
            }
            return list;


        }
    }
}
*/